<?php
require 'emp.php';
$id=  isset($_GET['id'])?$_GET['id']:0;
if (empty($_POST)){
$sp=$db->query("select * from tb_emp where e_id='{$id}'");
$rs=$sp->fetch_array();
require 'edit_html.php';
}  else {
$e_name=$_POST['e_name'];
$e_dept=$_POST['e_dept'];
$e_img=$_POST['e_img'];
$date_of_birth=$_POST['date_of_birth'];
$date_of_entry=$_POST['date_of_entry'];
$sp="update tb_emp set e_name='$e_name',e_dept='$e_dept',e_img='$e_img',date_of_birth='$date_of_birth',date_of_entry='$date_of_entry' where e_id='$id'";
$rs=$db->query($sp);
if($rs){
   echo '<script anguage="javascript">';
    echo 'alert("成功了！");';
    echo 'window.location.href="index.php"';
    echo '</script>';
}else{
    echo '<script anguage="javascript">';
    echo 'alert("失败了！");';
    echo 'window.location.href="index.php"';
    echo '</script>';
}
}
$db->close();